package com.service.impl;

import com.alibaba.druid.sql.visitor.functions.Right;
import com.mapper.RightMapper;
import com.pojo.RightClassOne;
import com.service.RightService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RightServiceImpl implements RightService {

    @Autowired
    private RightMapper rightMapper;

    public List<RightClassOne> findByFuzzy(RightClassOne rightClassOne) {
        return rightMapper.findFuzzyMainRight(rightClassOne);
    }

    public Boolean updateStatusByRightId(Integer rightId) {
        int row = rightMapper.updateStatusByRightId(rightId);
        if (row>0){
            return true;
        }
        return false;
    }

    public Boolean updateStatusFatherAndChild(Integer rightId) {
        int row = rightMapper.updateStatusByRightId(rightId);
        int i = rightMapper.updateStatusBySuperId(rightId);
        if (row>0&&i>0){
            return true;
        }
        return false;
    }

    public Boolean updateRight(RightClassOne rightClassOne) {
        int row = rightMapper.updateRight(rightClassOne);
        if (row>0){
            return true;
        }
        return false;
    }

    public List<RightClassOne> findMainRight() {
        List<RightClassOne> list = rightMapper.findMainRight();
        return list;
    }

    public Boolean addFrontRight(RightClassOne rightClassOne) {
        int row = rightMapper.addFrontRight(rightClassOne);
        if (row>0){
            return true;
        }
        return false;
    }

    public Boolean addBackgroundRight(RightClassOne rightClassOne) {
        int row = rightMapper.addBackgroundRight(rightClassOne);
        if (row>0){
            return true;
        }
        return false;
    }


}
